import 'package:flutter/material.dart';
import 'package:flutterlib/common/constants/constants.dart';
import 'package:flutterlib/common/net/dao_result.dart';
import 'package:flutterlib/common/utils/navigator_utils.dart';
import 'package:flutterlib/common/utils/utils.dart';
import 'package:flutterlib/pages/interest/list/interest_list_widget_page.dart';
import 'package:flutterlib/widgets/bussiness/post/interest_list_item.dart';
import 'package:thrio/thrio.dart';

///type = 0 获取我的或者是传入userid的兴趣
///type = 1 获取全部兴趣
class InterestSearchListWidgetPage extends InterestListWidgetPage {

  final String searchWord;

  InterestSearchListWidgetPage({Key key, this.searchWord}): super(key : key);


  @override
  InterestSearchListWidgetPageState createState() =>
      InterestSearchListWidgetPageState();
}

///页面 KeepAlive ，同时支持 动画Ticker
class InterestSearchListWidgetPageState
    extends InterestListWidgetPageState<InterestSearchListWidgetPage> {
  final SettingsStore store =
  Provider.of<SettingsStore>(currentContext, listen: false);
  getDataLogic(int page) async {
    print(page);


      var interests = allInterestsFromSP;
      interests = interests.where((element) => element.name.contains(widget.searchWord)).toList();
      trueDebugPrint("flutterting" + "flutterting allinterests" + interests?.length.toString());
      return new DataResult(interests, true);
  }

  Widget renderItem(index, interest) {
    //提交
    // var post = pullLoadWidgetControl.dataList[index];
    return InterestListItem(interest, onPressed: () {
      NavigatorUtils.gotoInterestDetail(context, interest.id);
    });
  }
}
